<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderDetailsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_details', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->char('order_number', 20)->default('')->comment('订单编号');
            $table->integer('goods_id')->comment('商品id');
            $table->integer('attr_id')->comment('商品属性id');
            $table->string('order_goodsname', 150)->comment('商品名称');
            $table->integer('order_goodsnumber')->default(1)->comment('商品数量');
            $table->decimal('order_price', 10,2)->default('0.00')->comment('商品单价');
            $table->decimal('order_totalprice', 10,2)->default('0.00')->comment('商品小计');
            $table->dateTime('order_dtime')->nullable()->comment('发货时间');
            $table->tinyInteger('order_status')->default(0)->comment('订单状态\r\n-1取消\r\n0未付款\r\n1未发货\r\n2待收货\r\n3待评价\r\n4已评价\r\n5退货申请\r\n6换货申请\r\n7已退货');
            $table->index('order_status');
            $table->index('order_number');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('order_details');
    }
}
